package com.intelligentclass.services;

import com.intelligentclass.entity.Homework;
import com.intelligentclass.repositories.HomeworkRespository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;

@Service
public class HomeworkService {

    private final HomeworkRespository homeworkRespository;

    public HomeworkService(HomeworkRespository homeworkRespository) {
        this.homeworkRespository = homeworkRespository;
    }

    public Homework getHomework(int hid) {
        return homeworkRespository.findById(hid).orElse(null);
    }

    public Homework getHomework(String hname, int cid){
        return homeworkRespository.findByHnameAndCid(hname, cid);
    }

    public Homework save(Homework homework){
        return homeworkRespository.save(homework);
    }
}
